﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/FullSite.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ToppingControl.Models.TopCordPlanModel.TopCordPlan_DS>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
   Header_line</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <style type="text/css">


.actived
{
   background-color: #20B2AA !important;
   
   color: White;
}
      
.hide
{
   disabled:disabled;
}
.fontBig
{
   font-size: 36pt;
   font-weight: bolder;
   
}
    
.btn
{
   font-size: 24px !important;
       
}
       

   </style>
   <div class="float-left">
      <h2>
         Topping Head Computer</h2>
   </div>
  
      
<div class="float-right">
<div class="float-left"><h3>Topping NO. 1 </h3></div>
<div class="float-left" style="margin-left:25px;"><h3>Shift : <%: ViewBag.shift %></h3></div>
<div class="float-left" style="margin-left:25px;"><h3>Name : 
<% if (Request.IsAuthenticated)
   { %>
<%:  User.Identity.Name %></h3></div>
<% } %>
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="MainContent2" runat="server">
    <div id="dialog-b" title="Authorize">
 <table style=" width:98%" class="">
   <tr class="rowa">
   <td class="head cell text-right"  style="padding:10px 0px; width:30%">Emp code</td>
   <td class="cell"><input type="text" id="txtempnm" style=" width:75% " /></td>

</tr>
   <tr class="rowa">
   <td class="head cell text-right"  style="padding:10px 0px;">Password</td>
   <td class="cell"><input type="password" id="txtpass" style=" width:75% " /></td>

</tr>
 <tr class="rowa">
   <td class="head cell text-right"  style="padding:10px 0px;">ShortText</td>
   <td class="cell"><input type="text" id="txtshort" style=" width:75% " /></td>

</tr>
       </table>
</div>

   <div style="height:5px; background:#fff; clear:both; margin-bottom:10px;"></div>     
   <table><tr><td>


     
      <% 
         
         var act = new ToppingControl.Models.TopCordPlanModel.TopCordPlan_DS();
         if (Model.Count()>0)
         {
            act = Model.First();
         }
         
         
         %>
     <div  class="float-left">     
     <button type="button" id="bt" class="shadow fontBig">
            <div id="seq" >
            </div>
            <div id="topped">
            </div>
            <div id="cus">
            </div>
            <div id="lens">
            </div>
         </button>
   
      <br />
            UPDATE PLAN :
        
      <div class="float-left" id="modi">
         
         <div id="pln"  class="float-left" >
         <%: act._UpTemp %> &nbsp;<%: act._Uptdat %>
         </div>
      </div>
  </div>
   <div style="width:750px; float:right; ">
      <table class=" shadow fontTB " id="dataTbl">
         <thead>
            <tr class="head">
               <td class="cell" style="width: 30%; line-height: 45px!important;">
                  SEQ
               </td>
               <td class="cell" style="width: 35%">
                  TOPPED CORD
               </td>
               <td class="cell" style="width: 30%">
                  MANUF.
               </td>
               <td class="cell" style="width: 10%;">
                  LENGTH.
               </td>
               <td class="cell" style="width: 50px; display: none;">
                  LENGTH.
               </td>
            </tr>
         </thead>
         <tbody>
            <%
               int i = 0;

               foreach (var item in Model)
               {
                  i = i + 1;
                  string upd = "";
                  string trrow = "rowa";
                  if (i % 2 == 0) trrow = "rowb";
                  string seq = item._Plandt + '-' + item._Itemno;
                  if (i == 1) {
                     trrow = trrow + " actived";
                     upd= item._UpTemp+ " : "+ item._Uptdat;
                  };
            %>
            <tr class='<%= trrow %>' style="line-height: 45px;">
               <td style="text-align: center;">
                  <%= seq %>
               </td>
               <td style="text-align: left;">
                  <%: Html.DisplayFor(modelItem => item._Topcrdcd) %>
               </td>
               <td style="text-align: left;">
                  <%: Html.DisplayFor(modelItem => item._Manufc) %>
               </td>
               <td style="text-align: center;">
                  <%: Html.DisplayFor(modelItem => item._Length) %>
               </td>
               <td style="width: 50px; text-align: center; display: none;">
                  <%= upd %>
               </td>
            </tr>
            <% } %>
         </tbody>
      </table>
   </div>
   
   </td></tr>
   </table>
</asp:Content>


<asp:Content ID="foot" ContentPlaceHolderID="TableContent" runat="server">
    <%--**************  Dialog ************--%>


<div style="clear: left; margin-top: 15px; ">
      <div class="float-left" style="margin-left: 10px">
         <% using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
            { %>
         <%: Html.AntiForgeryToken() %>
     <%--    <input type="button" value="EXIT" class="btn" style="height: 75px; width: 120px;"
            onclick="javascript:document.getElementById('logoutForm').submit()" />--%>
                <input type="button" value="EXIT" class="btnFooter shadow" style="height: 75px; width: 200px;"
            onclick="javascript:window.close();" />
         <% } %>
      </div>
           <div class="float-left" style="margin-left: 60px;">
         <input id="skip" type="button" value="SKIP"class="btnFooter shadow" style="height: 75px; width: 200px;" />
      </div>
      <div class="float-left" style="margin-left: 80px;">
         <input id="comuse" type="button" value="COMPOUND USED"class="btnFooter shadow" style="height: 75px; width: 250px;" />
      </div>
      <div class="float-right " style="margin-right:10px;">
         <input type="button" id="new" value="NEW / SAMPLE"class="btnFooter shadow "   style="height: 75px;
            width: 250px;" />
      </div>
   </div>   
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ScriptsSection" runat="server">
    <% if (false)
      { %>
   <script src="../../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
   <% } %>
   <script type="text/javascript">

       $(function () {

           if ($("tr.actived").length > 0) {
               var $tr = $("tr.actived:first");
               $("#seq").text($tr.find("td:eq(0)").text());
               $("#topped").text($tr.find("td:eq(1)").text());
               $("#cus").text($tr.find("td:eq(2)").text());
               $("#lens").text($tr.find("td:eq(3)").text());

           } 
            $("#new").removeAttr("disabled", "disabled");

           $("#bt").click(function () {
               if ($("tr.actived").length > 0) {
                   var url = '<%= Url.Action("Header_desc","HeaderLine") %>' + '?seq=' + $("#seq").text() + '&shift=' + '<%: ViewBag.shift %>';
                   window.location = url;
               }
           });
           var dialog = "";
           $("#new").click(function () {
               $("#dialog-b").dialog("open");
               dialog = "new"
           });
           $("#skip").click(function () {
               $("#dialog-b").dialog("open");
               dialog = "skip"
           });
           $("#comuse").click(function () {
               var url = '<%= Url.Action("Index","CPD_USE") %>';
               window.location = url;
           });

           $("#dialog-b").dialog({
               width: 650,
               height: 400,
               autoOpen: false,
               show: "blind",
               buttons: {
                   "Back": function () {
                       $(this).dialog("close");
                   },
                   "OK": function () {
                       if ($("#txtempnm").val() == "") {
                           alert("ระบุข้อมูลไม่ครบ");
                           $("#txtempnm").focus();
                           return;
                       }
                       if ($("#txtpass").val() == "") {
                           alert("ระบุข้อมูลไม่ครบ");
                           $("#txtpass").focus();
                           return;
                       }
                       if ($("#txtshort").val() == "") {
                           alert("ระบุข้อมูลไม่ครบ");
                           $("#txtshort").focus();
                           return;
                       }

                       $.post('<%=Url.Action("Get_Author","HeaderLine") %>' + '?users=' + $("#txtempnm").val() + '&pass=' + $("#txtpass").val()
                        , function (data) {
                            if (data.success == 0) {
                                alert(data.message);
                            }
                            else {
                                if (dialog == "new") {
                                    var url = '<%= Url.Action("New_Sample","HeaderLine") %>' + '?empnm=' + $("#txtempnm").val() + '&sTxt=' + $("#txtshort").val()+ '&refseq=' + $("#seq").text();
                                    window.location = url;
                                }
                                if (dialog == "skip") {
                                    var Surl = '<%= Url.Action("SKIP_ITEM","HeaderLine") %>' + '?seq=' + $("#seq").text();
                                    Surl = Surl + '&empnm=' + $("#txtempnm").val() + '&sTxt=' + $("#txtshort").val()
                                    $.post(Surl, function (data) {
                                        if (data.success == 0) {
                                            alert(data.message);
                                        } else {
                                            window.location.href = window.location.href;
                                        }
                                    });
                                }
                                $(this).dialog("close");

                            }
                        });
                   }
               }
           });


       });
   </script>
</asp:Content>
